﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace Maze
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void Form2_Load(object sender, EventArgs e)
        {
            StreamReader sr = new StreamReader("results.txt");
            List<int> scores = new List<int>();
            List<string> names = new List<string>();
            string[] tokens = sr.ReadToEnd().Split('\n');
            int n = tokens.Count()/2;
            for (int i = 0; i < n; ++i)
            {
                scores.Add(int.Parse(tokens[2*i]));
                names.Add(tokens[2*i+1]);
            }
            
            for (int i=0; i<n-1; ++i)
                for (int j=i+1; j<n; ++j)
                    if (scores[i] < scores[j])
                    {
                        int d = scores[i];
                        scores[i] = scores[j];
                        scores[j] = d;
                        string h = names[i];
                        names[i] = names[j];
                        names[j] = h;
                    }

            label1.Text = "1. " + scores[0] + " - " + names[0];
            label2.Text = "2. " + scores[1] + " - " + names[1];
            label3.Text = "3. " + scores[2] + " - " + names[2];
            label4.Text = "4. " + scores[3] + " - " + names[3];
            label5.Text = "5. " + scores[4] + " - " + names[4];
            label6.Text = "6. " + scores[5] + " - " + names[5];
            label7.Text = "7. " + scores[6] + " - " + names[6];
            label8.Text = "8. " + scores[7] + " - " + names[7];
            label9.Text = "9. " + scores[8] + " - " + names[8];
            label10.Text = "10. " + scores[9] + " - " + names[9];
            sr.Close();
            StreamWriter sw = new StreamWriter("results.txt");
            for (int i = 0; i < 10; ++i)
            {
                sw.WriteLine(scores[i]);
                sw.WriteLine(names[i]);
            }
            sw.Close();
        }

        private void label6_Click(object sender, EventArgs e)
        {

        }
    }
}
